#ifndef _BUTTONS_H_
#define _BUTTONS_H_

//check's should be called at 20ms
#define MIN_DEBOUNCE 	2

typedef enum {
	STATE_none = 0,
	STATE_pressed = 1,
	STATE_released = 2
} eButtonState_t;


typedef struct {
	uint8_t time;
	eButtonState_t state;
} stButton_t;


extern stButton_t butPage;
extern stButton_t butUp;
extern stButton_t butDn;


#define BUTTON_click(but,y)			((but.state == STATE_released) && (but.time < y))
#define BUTTON_held(but,y)			((but.state == STATE_pressed) && (but.time == y))
#define BUTTON_heldLonger(but, y)	((but.state == STATE_pressed) && (but.time > y))


void BUTTONS_init( stButton_t *b );
void BUTTONS_check( stButton_t *b, uint8_t input );

#endif
